package nz.co.doherty.gwtpbreadcrumbs.client.ui.app;

import nz.co.doherty.gwtpbreadcrumbs.client.ui.topbar.TopBarPresenter;

import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.inject.Inject;
import com.philbeaudoin.gwtp.mvp.client.EventBus;
import com.philbeaudoin.gwtp.mvp.client.PresenterImpl;
import com.philbeaudoin.gwtp.mvp.client.annotations.ContentSlot;
import com.philbeaudoin.gwtp.mvp.client.annotations.ProxyStandard;
import com.philbeaudoin.gwtp.mvp.client.proxy.Proxy;
import com.philbeaudoin.gwtp.mvp.client.proxy.RevealContentHandler;
import com.philbeaudoin.gwtp.mvp.client.proxy.RevealRootLayoutContentEvent;

/**
 * Top level presenter. Acts as a container for other presenters. The mapped
 * view is our top level layout structure.
 * 
 * @author Brendan Doherty
 * 
 */
public class AppPresenter extends
		PresenterImpl<AppView, AppPresenter.AppProxy> {

	@ContentSlot
	public static final Type<RevealContentHandler<?>> TYPE_RevealMainContent = new Type<RevealContentHandler<?>>();

	public static final Object TYPE_RevealTopBarContent = new Object();

	@ProxyStandard
	public interface AppProxy extends Proxy<AppPresenter> {

	}

	private final TopBarPresenter topBarPresenter;

	@Inject
	public AppPresenter(EventBus eventBus, AppView view, AppProxy proxy,
			TopBarPresenter topBarPresenter) {
		super(eventBus, view, proxy);

		this.topBarPresenter = topBarPresenter;
	}

	@Override
	protected void revealInParent() {
		RevealRootLayoutContentEvent.fire(eventBus, this);
	}

	@Override
	protected void onReveal() {
		super.onReveal();
		setContent(TYPE_RevealTopBarContent, topBarPresenter);
	}

}
